<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="icon" href="favicon.png" type="image/png">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--<link href="http://14th-test01.oss-cn-beijing.aliyuncs.com/bootstrap.min.css?Expires=1510459157&OSSAccessKeyId=TMP.AQHD0tQzFiQW8LBWAixLFU5aop7aieTbJEHMCXyvENrHJS7_vW5v_-J43zPaAAAwLAIUIOk9I_kvebjtKZzPws7jNkedwCECFD5C2cR-lhELmDwAHZ1P__l6gDLk&Signature=wVbhUi1x8nznFC51TKYaDnEcFH4%3D" rel="stylesheet">-->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel='stylesheet' href='/stylesheets/index.css' />
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js" ></script>
    <!--<script src="http://14th-test01.oss-cn-beijing.aliyuncs.com/jquery-1.11.3.min.js?Expires=1510459195&OSSAccessKeyId=TMP.AQHD0tQzFiQW8LBWAixLFU5aop7aieTbJEHMCXyvENrHJS7_vW5v_-J43zPaAAAwLAIUIOk9I_kvebjtKZzPws7jNkedwCECFD5C2cR-lhELmDwAHZ1P__l6gDLk&Signature=4zeSM2StGxYHpuSwBfZLDhew71w%3D" ></script>-->
    <script type="text/javascript" src="./lib/vue.min.js"></script>
    <!--<script type="text/javascript" src="http://14th-test01.oss-cn-beijing.aliyuncs.com/vue.js?Expires=1510459222&OSSAccessKeyId=TMP.AQHD0tQzFiQW8LBWAixLFU5aop7aieTbJEHMCXyvENrHJS7_vW5v_-J43zPaAAAwLAIUIOk9I_kvebjtKZzPws7jNkedwCECFD5C2cR-lhELmDwAHZ1P__l6gDLk&Signature=oAI4O5X0dMRtjq8j1BoVhMCe7Bk%3D"></script>-->
    <title>三月十四</title>
</head>
<body>


<script src="../javascripts/index_vue.js"></script>
<div id="vue_block" v-if="page.name">
    <div  class="container">
        <div class="blog-masthead">
            <div class="container">
                <nav class="blog-nav">
                    <span class="blog-nav-title">{{lang.title}}</span>
                    <a class="blog-nav-item active" v-show="!page.name||page.name==='index'" href="#" @click="router_index">Home</a>
                    <a class="blog-nav-item" href="#" v-show="!page.name||page.name==='index'">Code</a>
                    <a class="blog-nav-item" v-show="page.name&&page.name!=='index'" href="#" @click="router_index" style="display:none">Home</a>
                    <a class="blog-nav-item active" href="#" v-show="page.name&&page.name!=='index'" style="display:none">Code</a>
                    <!--<a class="blog-nav-item" href="#">New features</a>-->
                    <!--<a class="blog-nav-item" href="#">Press</a>-->
                    <!--<a class="blog-nav-item" href="#">New hires</a>-->

                </nav>
            </div>
        </div>
        <div class="blog-header" v-if="page.name">
            <h1 class="blog-title">{{lang.subtitle[1]}}</h1>
            <!--<p class="lead blog-description">陈宗豪 201592452 软日1505</p>-->
        </div>
        <div class="row">
            <div class="col-sm-4 blog-main" v-if="page.name==='index'">
                <div class="blog-post">

                    <template v-if="page.name==='index'">
                        <h2 class="blog-post-title">{{lang.subtitle[2]}}</h2>
                        <p class="blog-post-meta"><a href="#" @click="router_test(1)">{{lang.noun[1]}}01  2017- 9-28</a></p>
                        <p class="blog-post-meta"><a href="#" @click="router_test(2)">{{lang.noun[1]}}02  2017-10- 9</a></p>
                        <!--<p class="blog-post-meta"><a href="#" @click="router_test03">{{lang.noun[1]}}03  2017-10-23</a></p>-->
                        <p class="blog-post-meta"><a href="#" @click="router_test(3)">{{lang.noun[1]}}03 2017-10-26</a></p>
                        <p class="blog-post-meta"><a href="#" @click="router_test(4)">{{lang.noun[1]}}04 2017-10-23</a></p>
                    </template>
                </div>
            </div>
            <div class="col-sm-8 blog-main" v-if="page.name!=='index'">
                <div class="blog-post">
    <!------------------------------------------------标题部分------------------------------------------------------------->
                    <template v-if="page.name==='test01'">
                        <h2>{{lang.noun[1]}}01  词法分析</h2>
                        <p>2017-9-28 {{author.name}}</p>
                        <input  name="token" id="input_test01" @keydown="deal_test01">
                    </template>


                    <template v-if="page.name==='test02'">
                        <h2>{{lang.noun[1]}}02  求first集</h2>
                        <p>2017-10-9 {{author.name}}</p>
                        <textarea id="input_test02" rows="10" cols="50"></textarea><br>
                        <button type="button" @click="deal_test02">确认</button>
                    </template>

                    <!--<template v-if="page.name==='test03'">-->
                        <!--<h2>{{lang.noun[1]}}03  语法分析LR(1)</h2>-->
                        <!--<p>2017-10-23 {{author.name}}</p>-->
                        <!--<input  name="token" id="input_test03" @keydown="deal_test03">-->
                    <!--</template>-->
                    <template v-if="page.name==='test03'">
                        <h2>{{lang.noun[1]}}03  语法分析LL(1)</h2>
                        <p>2017-10-23 {{author.name}}</p>
                        <input  name="token" id="input_test03_2" @keydown="deal_test03_2">
                    </template>
                    <template v-if="page.name==='test04'">
                        <h2>{{lang.noun[1]}}04  语法分析LR(1)</h2>
                        <p>2017-10-23 {{author.name}}</p>
                        <input  name="token" id="input_test03" @keydown="deal_test03">
                    </template>
    <!--------------------------------------------------------------------------------------------------------------------->
                    <div v-if="!page.name">
                        {{lang.noun[2]}}……
                        <div class='loader loader--glisteningWindow'></div>
                    </div>
                    <div v-else-if="page.state='complete'&&page.name!=='index'">
                        <div id="output"></div>
                        <a href="#" @click="router_index">{{lang.noun[3]}}</a>
                    </div>

    <!------------------------------------------------代码部分------------------------------------------------------------->
                    <div id="code_test" v-show="page.name" style="display:none">
                        <!-----------------------编译------------------------------>
                        <!--<div id="code_test01" v-show="page.name==='test01'" style="display:none">-->
                            <!--<script src="https://code.csdn.net/snippets/2589295.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_test02" v-show="page.name==='test02'" style="display:none">-->
                            <!--<script src="https://code.csdn.net/snippets/2589294.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_test04" v-show="page.name==='test04'" style="display:none">-->
                            <!--<script src="https://code.csdn.net/snippets/2598514.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_test03_2" v-show="page.name==='test03'" style="display:none">-->
                            <!--<script src="https://code.csdn.net/snippets/2599735.js"></script>-->
                            <!--<script src="https://code.csdn.net/snippets/2599734.js"></script>-->
                        <!--</div>-->
                        <!-------------------------Hadoop-------------------------->
                        <!--<div id="code_hd01" v-show="page.name==='hd01'" style="display:none">-->
                            <!--<h2>求均值</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600846.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_hd02" v-show="page.name==='hd02'" style="display:none">-->
                            <!--<h2>求TopN</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600847.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_hd03" v-show="page.name==='hd03'" style="display:none">-->
                            <!--<h2>求最大值</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600848.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_hd04" v-show="page.name==='hd04'" style="display:none">-->
                            <!--<h2>wordcount</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600851.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_hd00" v-show="page.name==='hd00'" style="display:none;">-->
                            <!--<script src="https://code.csdn.net/snippets/2600855.js"></script>-->
                        <!--</div>-->
                        <!--<div id="code_hd05" v-show="page.name==='hd05'" style="display:none;">-->
                            <!--<h2>mapjoin</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600871.js"></script>-->
                        <!--</div  >-->
                        <!--<div id="code_hd06" v-show="page.name==='hd06'" style="display:none;">-->
                            <!--<h2>reducejoin</h2>-->
                            <!--<script src="https://code.csdn.net/snippets/2600873.js"></script>-->
                        <!--</div  >-->
                        <div v-show="page.name==='r00'">
                            <pre>
    wbcd <- read.csv("wisc_bc_data.csv", stringsAsFactors = FALSE)
    str(wbcd)
    wbcd <- wbcd[-1]
    table(wbcd$diagnosis)
    wbcd$diagnosis <- factor(
      wbcd$diagnosis,
      levels = c("B", "M"),
      labels = c("Benign", "Malignant")
    )
    round(prop.table(table(wbcd$diagnosis)) * 100, digits = 1)
    summary(wbcd[c("radius_mean", "area_mean", "smoothness_mean")])
    normalize <- function(x) {
      return ((x - min(x)) / (max(x) - min(x)))
    }
    wbcd_n <- as.data.frame(lapply(wbcd[2:31], normalize))
    summary(wbcd_n$area_mean)
    wbcd_train <- wbcd_n[1:469, ]
    wbcd_test <- wbcd_n[470:569, ]
    wbcd_train_labels <- wbcd[1:469, 1]
    wbcd_test_labels <- wbcd[470:569, 1]
    install.packages("class")
    library(class)
    wbcd_test_pred <- knn(
      train = wbcd_train,
      test = wbcd_test,
      cl = wbcd_train_labels, k=21
    )
    install.packages("gmodels")
    library(gmodels)
    CrossTable(
      x = wbcd_test_labels,
      y = wbcd_test_pred,
      prop.chisq=FALSE
    )
    wbcd_z <- as.data.frame(scale(wbcd[-1]))
    summary(wbcd_z$area_mean)
    wbcd_train <- wbcd_z[1:469, ]
    wbcd_test <- wbcd_z[470:569, ]
    wbcd_train_labels <- wbcd[1:469, 1]
    wbcd_test_labels <- wbcd[470:569, 1]
    wbcd_test_pred <- knn(
      train = wbcd_train,
      test = wbcd_test,
      cl = wbcd_train_labels,
      k=21
    )
    CrossTable(x = wbcd_test_labels, y = wbcd_test_pred,prop.chisq=FALSE)


    wbcd_test_pred <- knn(
      train = wbcd_train,
      test = wbcd_test,
      cl = wbcd_train_labels,
      k=5
    )
    CrossTable(x = wbcd_test_labels, y = wbcd_test_pred,prop.chisq=FALSE)

                            </pre>
                        </div>
                        <div id="code_r01" v-show="page.name==='r01'">
                            <pre>
    #--------------------------------------------------------------------------

    # @陈宗豪  2017-9-20

    #--------------------------------------------------------------------------

    #载入数据
    sms_raw <- read.csv("sms_spam.csv",stringsAsFactors = FALSE)
    str(sms_raw)
    #转化为factor
    sms_raw$type <- factor(sms_raw$type)
    str(sms_raw)
    table(sms_raw)

    #安装tm包
    install.packages("tm")
    library(tm)

    #--------------------------------------------------------------------------



    #语料库
    sms_corpus <- Corpus(VectorSource((sms_raw$text)))
    #inspect(sms_corpus[1:3])

    #清理数据
    corpus_clean <- tm_map(sms_corpus,tolower)
    corpus_clean <- tm_map(corpus_clean,removeNumbers)

    corpus_clean <- tm_map(corpus_clean , removeWords,stopwords())
    corpus_clean <- tm_map(corpus_clean , removePunctuation)
    corpus_clean <- tm_map(corpus_clean , stripWhitespace)
    #inspect(sms_corpus[1:3])




    #--------------------------------------------------------------------------

    sms_dtm <- DocumentTermMatrix(corpus_clean)

    #数据准备
    #分解原始数据框
    sms_raw_train <- sms_raw[1:4168,]#训练数据
    sms_raw_test <- sms_raw[4170:5558,]#测试数据

    sms_dtm_train <- sms_dtm[1:4168,]
    sms_dtm_test <- sms_dtm[4170:5558,]

    sms_corpus_train <- corpus_clean[1:4168]
    sms_corpus_test <- corpus_clean[4170:5558]


    #--------------------------------------------------------------------------

    #数据可视化  wordcloud

    #安装
    install.packages("wordcloud")
    library(wordcloud)

    wordcloud(sms_corpus_train, min.freq = 40,random.order = FALSE)
    spam <- subset(sms_raw_train,type == "spam")
    ham <- subset(sms_raw_train,type=="ham")
    #垃圾短信词云
    wordcloud(spam$text, max.words = 40,scale = c(3,0.5))
    #普通短信词云
    wordcloud(ham$text, max.words = 40,scale = c(3,0.5))

    sms_dict <- findFreqTerms(sms_dtm_train , 5)

    sms_train <- DocumentTermMatrix(sms_corpus_train,list(dictionary = sms_dict))
    sms_test <- DocumentTermMatrix(sms_corpus_test, list(dictionary = sms_dict))

    convert_counts <- function(x){
    x<- ifelse(x >0 ,1,0)
    x <- factor(x, levels = c(0,1), labels = c("No","Yes"))
    return(x)
    }

    sms_train <- apply(sms_train,MARGIN=2 ,convert_counts)
    sms_test <- apply(sms_test,MARGIN=2 , convert_counts)

    #--------------------------------------------------------------------------
    #安装朴素贝叶斯算法实现
    install.packages("e1071")
    library(e1071)

    #--------------------------------------------------------------------------
    #给予sms_train建立模型
    sms_classifier <- naiveBayes(sms_train,sms_raw_train$type)

    #评估模型性能
    sms_test_pred <- predict(sms_classifier,sms_test)
    install.packages("gmodels")
    library(gmodels)

    CrossTable(sms_test_pred,sms_raw_test$type,
    prop.chisq = FALSE, prop.t = FALSE,
    dnn = c('predicted','actual'))

    #--------------------------------------------------------------------------
    #提升模型性能

    sms_classifier2 <- naiveBayes(sms_train , sms_raw_train$type,
    laplace = 1)
    sms_test_pred2 <- predict(sms_classifier2, sms_test)
    CrossTable(sms_test_pred2,sms_raw_test$type,
    prop.chisq = FALSE,prop.t = FALSE,prop.r = FALSE,
    dnn = c('predicted','actual'))
    #--------------------------------------------------------------------------

                            </pre>
                        </div>
                        <div v-show="page.name==='r02'">
                            <pre>
    credit <- read.csv("credit.csv")
    str(credit)
    table(credit$checking_balance)
    table(credit$savings_balance)
    summary(credit$months_loan_duration)
    summary(credit$amount)
    table(credit$default)
    set.seed(12345)
    credit_rand <- credit[order(runif(1000)), ]
    summary(credit$amount)
    summary(credit_rand$amount)
    head(credit$amount)
    head(credit_rand$amount)
    credit_train <- credit_rand[1:900, ]
    credit_test  <- credit_rand[901:1000, ]
    prop.table(table(credit_train$default))
    prop.table(table(credit_test$default))
    install.packages("C50")
    library(C50)
    #默认参数
    credit_model <- C5.0(credit_train[-17], credit_train$default)
    credit_model
    summary(credit_model)
    credit_pred <- predict(credit_model, credit_test)
    library(gmodels)
    CrossTable(credit_test$default, credit_pred,prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE, dnn = c('actual default', 'predicted default'))
    #boost
    credit_boost10 <- C5.0(credit_train[-17], credit_train$default,trials = 10)
    credit_boost10
    summary(credit_boost10)
    credit_boost_pred10 <- predict(credit_boost10, credit_test)
    CrossTable(credit_test$default, credit_boost_pred10, prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE, dnn = c('actual default', 'predicted default'))
    #改变代价矩阵
    error_cost <- matrix(c(0, 1, 4, 0), nrow = 2)
    error_cost
    credit_cost<-C5.0(credit_train[-17], credit_train$default, costs = error_cost)
    credit_cost_pred <- predict(credit_cost, credit_test)
    CrossTable(credit_test$default, credit_cost_pred, prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE,dnn = c('actual default', 'predicted default'))
                            </pre>
                        </div>
                        <div v-show="page.name==='r03'">
                            <pre>
    mushrooms <- read.csv("mushrooms.csv", stringsAsFactors = TRUE)
    str(mushrooms)
    #去除没用的veil_type
    mushrooms$veil_type <- NULL
    table(mushrooms$type)
    library(RWeka)
    #1R
    mushroom_1R <- OneR(type ~ ., data = mushrooms)
    mushroom_1R
    summary(mushroom_1R)
    #RIPPER
    mushroom_JRip <- JRip(type ~ ., data = mushrooms)
    mushroom_JRip
                            </pre>
                        </div>
                        <div v-show="page.name==='r04'">
                            <pre>
    insurance <- read.csv("insurance.csv", stringsAsFactors = TRUE)
    str(insurance)

    summary(insurance$expenses)

    hist(insurance$expenses)

    table(insurance$region)

    cor(insurance[c("age", "bmi", "children", "expenses")])

    pairs(insurance[c("age", "bmi", "children", "expenses")])

    install.packages("psych")
    library(psych)
    pairs.panels(insurance[c("age", "bmi", "children", "expenses")])

    ins_model <- lm(expenses ~ age + children + bmi + sex + smoker + region,
                    data = insurance)
    ins_model <- lm(expenses ~ ., data = insurance)
    ins_model

    summary(ins_model)

    insurance$age2 <- insurance$age^2

    insurance$bmi30 <- ifelse(insurance$bmi >= 30, 1, 0)

    charges ~ bmi30 + smokeryes + bmi30:smokeryes

    ins_model2 <- lm(expenses ~ age + age2 + children + bmi + sex +
                       bmi30*smoker + region, data = insurance)

    summary(ins_model2)


                            </pre>
                        </div>
                        <div v-show="page.name==='r05'">
                            <pre>
    #encoding-CP936

    windows()

    #读取数据 concrete.csv
    concrete <- read.csv("concrete.csv")
    #查看数据结构
    str(concrete)
    #自定义函数将数据标准化到0~1范围
    normalize <- function(x) {
      return((x - min(x)) / (max(x) - min(x)))
    }
    #将normalize()应用于数据框每一列
    concrete_norm <- as.data.frame(lapply(concrete, normalize))
    #确认是否标准化（最小为0最大为1）
    summary(concrete_norm$strength)
    #查看原始数据最大最小值
    summary(concrete$strength)

    #数据处理 分割比例3：1
    concrete_train <- concrete_norm[1:773, ]
    concrete_test <- concrete_norm[774:1030, ]

    #安装 neuralnet包 并加载
    install.packages("neuralnet")
    library(neuralnet)

    #绘制网络拓扑结构
    concrete_model <- neuralnet(strength ~ cement + slag + ash + water +
                                  superplastic + coarseagg + fineagg +
                                  age,data = concrete_train)
    #可视化网络拓扑结构
    plot(concrete_model)
    #基于测试数据建立模型
    model_results <- compute(concrete_model, concrete_test[1:8])
    #提取出 $net.results
    predicted_strength <- model_results$net.result
    #获取两个数值向量的相关性
    cor(predicted_strength, concrete_test$strength)
    #增加参数 hidden=5
    concrete_model2 <- neuralnet(strength ~ cement + slag + ash + water +
                                 superplastic + coarseagg + fineagg + age,
                                 data = concrete_train, hidden = 5)
    plot(concrete_model2)
    #基于测试数据建立模型
    model_results2 <- compute(concrete_model2, concrete_test[1:8])
    #提取出 $net.results
    predicted_strength2 <- model_results2$net.result
    #获取两个数值向量的相关性
    cor(predicted_strength2, concrete_test$strength)


                            </pre>
                        </div>
                        <div v-show="page.name==='r06'"><pre>
    wine <- read.csv("whitewines.csv")

    str(wine)

    hist(wine$quality)

    summary(wine)

    wine_train <- wine[1:3750, ]
    wine_test <- wine[3751:4898, ]

    install.packages("rpart")
    library(rpart)
    m.rpart <- rpart(quality ~ ., data = wine_train)

    m.rpart

    summary(m.rpart)

    install.packages("rpart.plot")
    library(rpart.plot)

    rpart.plot(m.rpart, digits = 3)

    rpart.plot(m.rpart, digits = 4, fallen.leaves = TRUE, type = 3, extra = 101)

    p.rpart <- predict(m.rpart, wine_test)

    summary(p.rpart)
    summary(wine_test$quality)

    cor(p.rpart, wine_test$quality)

    MAE <- function(actual, predicted) {
      mean(abs(actual - predicted))
    }

    MAE(p.rpart, wine_test$quality)

    mean(wine_train$quality)
    MAE(5.87, wine_test$quality)

    library(RWeka)
    m.m5p <- M5P(quality ~ ., data = wine_train)

    m.m5p

    summary(m.m5p)

    p.m5p <- predict(m.m5p, wine_test)

    summary(p.m5p)

    cor(p.m5p, wine_test$quality)

    MAE(wine_test$quality, p.m5p)

                        </pre></div>
                        <div v-show="page.name==='r07'"><pre>
    letters <- read.csv("letterdata.csv")
    str(letters)
    letters_train <- letters[1:16000, ]
    letters_test  <- letters[16001:20000, ]
    install.packages("kernlab")
    library(kernlab)
    letter_classifier <- ksvm(letter ~ ., data = letters_train,kernel = "vanilladot")
    letter_classifier
    letter_predictions <- predict(letter_classifier, letters_test)
    head(letter_predictions)
    table(letter_predictions, letters_test$letter)
    agreement <- letter_predictions == letters_test$letter
    table(agreement)
    prop.table(table(agreement))
    letter_classifier_rbf <- ksvm(letter ~ ., data = letters_train,kernel = "rbfdot")
    letter_predictions_rbf <- predict(letter_classifier_rbf,letters_test)
    agreement_rbf <- letter_predictions_rbf == letters_test$letter
    table(agreement_rbf)
    prop.table(table(agreement_rbf))

                        </pre></div>
                        <div v-show="page.name==='r08'"><pre>
    install.packages("arules")
    library(Matrix)
    library(arules)
    groceries <- read.transactions("groceries.csv", sep = ",")
    summary(groceries)
    inspect(groceries[1:5])
    itemFrequency(groceries[, 1:3])
    itemFrequencyPlot(groceries, support = 0.1)
    itemFrequencyPlot(groceries, topN = 20)
    image(groceries[1:5])
    image(sample(groceries, 100))
    apriori(groceries)
    groceryrules <- apriori(groceries, parameter = list(support =
                                0.006, confidence = 0.25, minlen = 2))
    groceryrules
    summary(groceryrules)
    inspect(groceryrules[1:3])
    inspect(sort(groceryrules, by = "lift")[1:5])
    berryrules <- subset(groceryrules, items %in% "berries")
    inspect(berryrules)
    write(groceryrules, file = "groceryrules.csv", sep = ",", quote = TRUE, row.names = FALSE)
    groceryrules_df <- as(groceryrules, "data.frame")
    str(groceryrules_df)

                        </pre></div>
                        <div v-show="page.name==='r09'"><pre>
    teens <- read.csv("snsdata.csv")
    str(teens)
    table(teens$gender)
    table(teens$gender, useNA = "ifany")
    summary(teens$age)
    teens$age <- ifelse(teens$age >= 13 & teens$age < 20,teens$age, NA)
    summary(teens$age)
    teens$female <- ifelse(teens$gender == "F" & !is.na(teens$gender), 1, 0)
    teens$no_gender <- ifelse(is.na(teens$gender), 1, 0)
    table(teens$gender, useNA = "ifany")
    table(teens$female, useNA = "ifany")
    table(teens$no_gender, useNA = "ifany")
    mean(teens$age)
    mean(teens$age, na.rm = TRUE)
    aggregate(data = teens, age ~ gradyear, mean, na.rm = TRUE)
    ave_age <- ave(teens$age, teens$gradyear, FUN = function(x) mean(x, na.rm = TRUE))
    teens$age <- ifelse(is.na(teens$age), ave_age, teens$age)
    summary(teens$age)
    interests <- teens[5:40]
    interests_z <- as.data.frame(lapply(interests, scale))
    teen_clusters <- kmeans(interests_z, 5)
    teen_clusters$size
    teen_clusters$centers
    teens$cluster <- teen_clusters$cluster
    teens[1:5, c("cluster", "gender", "age", "friends")]
    aggregate(data = teens, age ~ cluster, mean)
    aggregate(data = teens, female ~ cluster, mean)
    aggregate(data = teens, friends ~ cluster, mean)

                        </pre></div>
                        <a href="#" @click="router_index">{{lang.noun[3]}}</a>
                        <a href="#">{{lang.noun[4]}}</a>
                    </div>
    <!--------------------------------------------------------------------------------------------------------------------->



                 </div>
            </div>
            <div class="col-sm-4 blog-main" v-if="page.name==='index'">
                <div class="blog-post">
                        <template v-if="page.name==='index'">
                            <h2 class="blog-post-title"><a href="#"  style="color:#555; text-decoration:none">R{{lang.subtitle[3]}}</a></h2>
                            <p class="blog-post-meta"><a href="#" @click="router_r('00')">KNN             - 诊断乳腺癌</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('01')">朴素贝叶斯分类   - 垃圾邮件</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('02')">C5.0            - 银行风险贷款</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('03')">规则学习         - 毒蘑菇</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('04')">线性回归         - 预测医疗费用</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('05')">神经网络         - 混凝土的强度进行建模</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('06')">回归树模型树     - 葡萄酒质量</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('07')">支持向量机       - 光学字符识别</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('08')">探寻模式         - 基于关联规则的购物篮分析</a></p>
                            <p class="blog-post-meta"><a href="#" @click="router_r('09')">寻找数据的分组   - k均值聚类</a></p>
                        </template>
                </div>
            </div>
            <div class="col-sm-3 col-md-offset-1 blog-sidebar">
                <div class="sidebar-module sidebar-module-inset">
                    <h4>{{lang.subtitle[4]}}</h4>
                    <ul>
                        <li v-show="page.name" v-for="list in event_list" style="display:none">
                            {{list.text}}
                        </li>
                    </ul>

                </div>
                <div class="sidebar-module">
                    <h4>{{lang.subtitle[5]}}</h4>
                    <ol class="list-unstyled">
                        <li><a href="#">2017年10月</a></li>

                    </ol>
                </div>
                <div class="sidebar-module">
                    <h4>{{lang.subtitle[6]}}</h4>
                    <ol class="list-unstyled">
                        <li><a href="http://14th.top/mrs">OpenMRS项目前端</a></li>
                        <li><a href="http://li.14th.top">银行系统（软工作业）</a></li>
                        <li><a href="http://ncair.14th.top">航空系统（软工作业）</a></li>
                        <li><a href="https://github.com/">GitHub</a></li>
                        <li><a href="https://cn.vuejs.org/">vuejs中文网</a></li>
                        <li><a href="http://nodejs.cn/">nodejs中文网</a></li>
                    </ol>
                </div>
            </div><!-- /.blog-sidebar -->

        </div>
    </div>
    <footer class="blog-footer">

            <p><a href="#" @click="lan('zh-cn')">简体中文</a>|
        <a href="#" @click="lan('zh-tw')">繁体中文</a>|
        <a href="#" @click="lan('jp')">日本語</a>|
        <a href="#" @click="lan('en')">English</a></p>
        <p> 联系方式  QQ:793340483  E-Mail:chzh314@hotmail.com</p>
        <p>
            <a href="http://www.miitbeian.gov.cn/">辽ICP备17018178号-1</a>
        </p>
    </footer>
</div>
<script src="../javascripts/prefixfree.min.js"></script>
<!--<script src="http://14th-test01.oss-cn-beijing.aliyuncs.com/prefixfree.min.js?Expires=1510459258&OSSAccessKeyId=TMP.AQHD0tQzFiQW8LBWAixLFU5aop7aieTbJEHMCXyvENrHJS7_vW5v_-J43zPaAAAwLAIUIOk9I_kvebjtKZzPws7jNkedwCECFD5C2cR-lhELmDwAHZ1P__l6gDLk&Signature=AhcGJ7qIhp1IfOYmdcAzHxOYXg0%3D"></script>-->
<script src="../javascripts/modernizr.js"></script>
<!--<script src="http://14th-test01.oss-cn-beijing.aliyuncs.com/modernizr.js?Expires=1510459282&OSSAccessKeyId=TMP.AQHD0tQzFiQW8LBWAixLFU5aop7aieTbJEHMCXyvENrHJS7_vW5v_-J43zPaAAAwLAIUIOk9I_kvebjtKZzPws7jNkedwCECFD5C2cR-lhELmDwAHZ1P__l6gDLk&Signature=lvUi873QgqoC7sXcrXPcwDvuyDs%3D"></script>-->
<!--<script src="javascripts/reactrender.js"></script>-->
<!--<script src="dist/js/bootstrap.js"></script>-->
</body>
</html>